home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / GX Libraries / UserLibrary.c < prev   
Encoding:
C/C++ Source or Header  |  1995-03-31  |  1.6 KB  |  73 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        UserLibrary.c
  4.  
  5.     Contains:    graphics libraries - user library
  6.     
  7.     Written by:    Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
  8.     
  9.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <1>      1/9/95    JD        First checked in.
  14. */
  15.  
  16. #include "GraphicsLibraries.h"
  17.  
  18. void DisposeTagAt(gxTag *oldTag)
  19. {
  20.     NilParamReturn(oldTag);
  21.     if (*oldTag) {
  22.         GXDisposeTag(*oldTag);
  23.         *oldTag = nil;
  24.     }
  25. }
  26.  
  27. void AddShapeUser(gxShape source, const void *data, long length, long type)
  28. {
  29.     gxTag tempItem;
  30.  
  31.     tempItem = GXNewTag(type, length, data);
  32.     GXSetShapeTags(source, 0, 0, 0, 1, &tempItem);
  33.     GXDisposeTag(tempItem);
  34. }
  35.  
  36. long GetShapeUser(gxShape source, void *data, long *length, long requestedType, long *foundType, long index)
  37. {
  38.     if( length )
  39.         *length = 0;
  40.  
  41.     if( index )
  42.     {
  43.         gxTag tempItem;
  44.  
  45.         if( GXGetShapeTags(source, requestedType, index, 1, &tempItem) )
  46.         {
  47.             register long tempLength;
  48.  
  49.             tempLength = GXGetTag(tempItem, foundType, data);
  50.             if( length )
  51.                 *length = tempLength;
  52.             return index;
  53.         }
  54.  
  55.         return 0;
  56.     }
  57.     else
  58.         return GXGetShapeTags(source, requestedType, 1, gxSelectToEnd, nil);
  59. }
  60.  
  61. void RemoveShapeUser(gxShape source, long type, long index)
  62. {
  63.     register long count = 1;
  64.  
  65.     if( index == 0 )        /* remove all user items of the specified type */
  66.     {
  67.         count = gxSelectToEnd;
  68.         index = 1;
  69.     }
  70.  
  71.     GXSetShapeTags(source, type, index, count, 0, nil);
  72. }
  73.